#include <buola/scene/techniques/ccoordstechnique.h>
#include <buola/scene/crendercontext.h>

#include "shaders/sVertexShaderCoords.h"
#include "shaders/sFragmentShaderCoords.h"

namespace buola { namespace scene {

CCoordsTechnique::CCoordsTechnique()
{
    mProgram.CreateAndAttach(shaders::sVertexShaderCoords,shaders::sFragmentShaderCoords);
    mProgram.BindFragmentData(0,"oFragColor");
    mProgram.BindFragmentData(1,"oPos");
    mProgram.BindAttribLocation(0,"iVertex");
    mProgram.BindAttribLocation(1,"iColor");
    mProgram.BindAttribLocation(2,"iNormal");
    mProgram.Link();

    uMVMatrix=mProgram.GetUniform("uMVMatrix");
    uMVPMatrix=mProgram.GetUniform("uMVPMatrix");
}

CCoordsTechnique::~CCoordsTechnique()
{
    
}

void CCoordsTechnique::Prepare(CRenderContext &pContext)
{
    if(pContext.mTechnique!=this)
    {
        mProgram.Use();
        pContext.mTechnique=this;
    }

//    uTransformation.SetValue(pContext.mProjectionMatrix*pContext.mViewMatrix*pContext.mModelMatrix);
}

CCoordsTechnique *CCoordsTechnique::Get()
{
    static CCoordsTechnique *lTechnique=new CCoordsTechnique;
    return lTechnique;
}

/*namespace scene*/ } /*namespace buola*/ }